@echo off

set MODEL=x64

call "%~dp0\build\tools\init.cmd"
call %VSVARSALLBAT% %MODEL%

call :do_prepare Debug
call :do_prepare Release

echo Done.

goto :eof

:::::::::::::::::::::::::::::::::::::
:do_prepare
setlocal

set CFG=%1
set REP_ROOT=%~dp0
set BUILD_DIR=%REP_ROOT%nmake_%CFG%
set PROJECT_DIR=%REP_ROOT%

set CMAKE_CMD="c:\Program Files (x86)\CMake 2.8\bin\cmake.exe"
set CMAKE_GENERATOR=-G "NMake Makefiles" -DCMAKE_BUILD_TYPE=%CFG% -DBUILD_X64=ON
set CMAKE_OPTIONS=%CMAKE_GENERATOR% "%PROJECT_DIR%"

REM if EXIST "%BUILD_DIR%" (
REM echo Removing "%BUILD_DIR%" dir...
REM rmdir /S/Q "%BUILD_DIR%"
REM )

if NOT EXIST "%BUILD_DIR%" (
echo Creating new "%BUILD_DIR%" dir...
mkdir "%BUILD_DIR%"
)

echo Calling CMake...
pushd "%BUILD_DIR%"
%CMAKE_CMD% %CMAKE_OPTIONS%
::nmake all
popd

goto :eof
